class Solution:
    #
    # def suffix_max(self, i):
    #     if i == 0:
    #         return self.nums[0]
    #     pre = self.suffix_max(i - 1)
    #     cur = pre + self.nums[i] if pre > 0 else self.nums[i]
    #     self.full_max = max(cur, self.full_max)
    #     return cur
    #
    # def maxSubArray(self, nums):
    #     self.full_max = nums[0]
    #     self.nums = nums
    #     self.suffix_max(len(nums) - 1)
    #     return self.full_max
    #
    # def maxSubArray(self,nums):
    #     end={}
    #     end[0]=nums[0]
    #     full_max=end[0]
    #     for i in range(1,len(nums)):
    #         end[i]=end[i-1]+nums[i] if end[i-1]>0 else nums[i]
    #         full_max=max(full_max,end[i])
    #     return full_max

    def maxSubArray(self,nums):
        suffix_max=nums[0]
        full_max=suffix_max
        for i in range(1,len(nums)):
            suffix_max=suffix_max+nums[i] if suffix_max>0 else nums[i]
            full_max=max(suffix_max,full_max)
        return full_max